﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using RED_NET_Core.Entity;
using RED_NET_Core.Utilty;
using RED_NET_Core.Helper;
using System.Data.SqlClient;
namespace RED_NET_Core.DAL
{
    class UserInfoDAL
    {

        #region[用户自己修改密码]

        /// <summary>
        /// 修改自己的密码
        /// </summary>
        /// <param name="newPassword">新密码</param>
        /// <returns></returns>
        public static void UpdateMyPassword(int uid,string newPassword)//,string newAvatarUrl)
        {
            SqlHelper helper = new SqlHelper();
            string smdStr = "update _Users set _Password=@Password where _UId='"+uid.ToString()+"'";
            SqlParameter[] param = new SqlParameter[1];

            param[0] = new SqlParameter("@Password", newPassword);
 
            OwnSqlHelper _shp = new OwnSqlHelper();
            try
            {
                _shp.ExecuteNonQuery(smdStr, param, System.Data.CommandType.Text);
            }
            catch (Exception ex)
            {
                throw ex;

            }
     
        }
        #endregion

        #region[用户自己修改头像]

        /// <summary>
        /// 修改自己的头像
        /// </summary>
        /// <param name="newPassword">新图片地址</param>
        /// <returns></returns>
        public static  void UpdateMyAvatar(int uid,string avatarUrl)//,string newAvatarUrl)
        {
            SqlHelper helper = new SqlHelper();
            string smdStr = "update _Users set _AvatarUrl=@AvatarUrl where _UId=@UId";
            SqlParameter[] param = new SqlParameter[2];

            param[0] = new SqlParameter("@AvatarUrl", avatarUrl);
            param[1] = new SqlParameter("@UId", uid.ToString());
          
            OwnSqlHelper _shp = new OwnSqlHelper();
            try
            {
                _shp.ExecuteNonQuery(smdStr, param, System.Data.CommandType.Text);
            }
            catch (Exception ex)
            {
                throw ex;
       
            }
           
        }

        #endregion




    }
}
